﻿@using NewLife;
@using NewLife.Common;
@using NewLife.Cube.Areas.Admin.Models;
@model LoginViewModel
@{
    Layout = null;
    ViewBag.Title = "登录";
    var set = Model;
    var loginTip = NewLife.Cube.Setting.Current.LoginTip;
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title - @SysConfig.Current.DisplayName</title>
    <meta name="description" content="@SysConfig.Current.Company">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="~/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700" />
    <link href="~/assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
    <link href="~/assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
</head>
<body id="kt_body" class="bg-white">
    <div class="d-flex flex-column flex-root">
        <div class="d-flex flex-column flex-lg-row flex-column-fluid">
            <div class="d-flex flex-column flex-lg-row-auto w-xl-1000px positon-xl-relative" style="background-image: url(../../assets/media/bg-4.jpg) ">
                <div class="d-flex flex-column position-xl-fixed top-0 bottom-0 w-xl-1000px scroll-y">
                    <div class="d-flex flex-row-fluid flex-column text-center p-10 pt-lg-20">
                        <h1 class="fw-bolder fs-3x pb-5 pb-md-10 text-white 1h-x">@SysConfig.Current.DisplayName</h1>
                        <p class="fw-bold fs-3 text-muted">
                            @SysConfig.Current.Company
                            <br />
                        </p>

                    </div>
                    <div class="d-flex flex-row-auto bgi-no-repeat bgi-position-x-center bgi-size-contain bgi-position-y-bottom min-h-100px min-h-lg-350px" style="background-image: url(../../assets/media/verification.png) "></div>
                </div>
            </div>

            <div class="d-flex flex-column flex-lg-row-fluid">
                <!-- 登录提示信息 -->
                @if (!loginTip.IsNullOrEmpty())
                {
                    <div class="alert alert-dismissible bg-info d-flex flex-column flex-sm-row w-100 p-5 mb-10">
                        <span class="svg-icon svg-icon-2hx svg-icon-light me-4 mb-5 mb-sm-0">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
                                <path opacity="0.3" d="M12 22C13.6569 22 15 20.6569 15 19C15 17.3431 13.6569 16 12 16C10.3431 16 9 17.3431 9 19C9 20.6569 10.3431 22 12 22Z" fill="black"></path>
                                <path d="M19 15V18C19 18.6 18.6 19 18 19H6C5.4 19 5 18.6 5 18V15C6.1 15 7 14.1 7 13V10C7 7.6 8.7 5.6 11 5.1V3C11 2.4 11.4 2 12 2C12.6 2 13 2.4 13 3V5.1C15.3 5.6 17 7.6 17 10V13C17 14.1 17.9 15 19 15ZM11 10C11 9.4 11.4 9 12 9C12.6 9 13 8.6 13 8C13 7.4 12.6 7 12 7C10.3 7 9 8.3 9 10C9 10.6 9.4 11 10 11C10.6 11 11 10.6 11 10Z" fill="black"></path>
                            </svg>
                        </span>
                        <div class="d-flex flex-column text-light pe-0 pe-sm-10">
                            <h4 class="mb-2 text-light">登录提示</h4>
                            <span>@loginTip</span>
                        </div>
                        <button type="button" class="position-absolute position-sm-relative m-2 m-sm-0 top-0 end-0 btn btn-icon ms-sm-auto" data-bs-dismiss="alert">
                            <span class="svg-icon svg-icon-2x svg-icon-light">
                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
                                    <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black"></rect>
                                    <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black"></rect>
                                </svg>
                            </span>
                        </button>
                    </div>
                }

                <!-- 登录校验信息 -->
                @if (Html.ValidationSummary(true).ToDictionary().Count()>1)
                {
                    <div class="alert alert-dismissible bg-light-danger border border-danger border-dashed d-flex flex-column flex-sm-row m-10">
                        <!--begin::Icon-->
                        <!--begin::Svg Icon | path: icons/duotone/Interface/Comment.svg-->
                    <span class="svg-icon svg-icon-2hx svg-icon-danger me-4 mb-5 mb-sm-0">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
                                <path opacity="0.25" fill-rule="evenodd" clip-rule="evenodd" d="M5.69477 2.48932C4.00472 2.74648 2.66565 3.98488 2.37546 5.66957C2.17321 6.84372 2 8.33525 2 10C2 11.6647 2.17321 13.1563 2.37546 14.3304C2.62456 15.7766 3.64656 16.8939 5 17.344V20.7476C5 21.5219 5.84211 22.0024 6.50873 21.6085L12.6241 17.9949C14.8384 17.9586 16.8238 17.7361 18.3052 17.5107C19.9953 17.2535 21.3344 16.0151 21.6245 14.3304C21.8268 13.1563 22 11.6647 22 10C22 8.33525 21.8268 6.84372 21.6245 5.66957C21.3344 3.98488 19.9953 2.74648 18.3052 2.48932C16.6859 2.24293 14.4644 2 12 2C9.53559 2 7.31411 2.24293 5.69477 2.48932Z" fill="#191213"></path>
                                <path fill-rule="evenodd" clip-rule="evenodd" d="M7 7C6.44772 7 6 7.44772 6 8C6 8.55228 6.44772 9 7 9H17C17.5523 9 18 8.55228 18 8C18 7.44772 17.5523 7 17 7H7ZM7 11C6.44772 11 6 11.4477 6 12C6 12.5523 6.44772 13 7 13H11C11.5523 13 12 12.5523 12 12C12 11.4477 11.5523 11 11 11H7Z" fill="#121319"></path>
                            </svg>
                        </span>
                        <!--end::Svg Icon-->
                        <!--end::Icon-->
                        <!--begin::Content-->
                    <div class="d-flex flex-column pe-0 pe-sm-10">
                            <h5 class="mb-1 text-danger">信息</h5>
                            <span class="text-danger">@Html.ValidationSummary()</span>
                        </div>
                        <!--end::Content-->
                        <!--begin::Close-->
                    <button type="button" class="position-absolute position-sm-relative m-2 m-sm-0 top-0 end-0 btn btn-icon ms-sm-auto" data-bs-dismiss="alert">
                            <i class="fas fa-times fs-1 text-danger"></i>
                        </button>
                        <!--end::Close-->
                </div>

                }
                <!--begin::Content-->
                <div class="d-flex flex-center flex-column flex-column-fluid">
                    <!--begin::Wrapper-->
                    <div class="w-sm-500px p-10 p-lg-15 mx-auto">
                        <div class="text-center mb-10">
                            <h1 class="text-dark mb-3">
                                <a href="#" class="py-9">
                                    <img alt="Logo" src="~/assets/media/logos/Logo.png" class="h-90px" />
                                </a>
                            </h1>
                        </div>

                        <div class="tab-content">
                            <!-- 登录界面 -->
                            <div id="Pane_Login" class="tab-pane fade show active">
                                <!--begin::Form-->
                                <form action="@Url.Action("Login", "User", new { r = set.ReturnUrl })" method="post" id="kt_sign_in_form">
                                    <!--begin::Heading-->
                                    <div class="fv-row mb-5">
                                        <label class="form-label fs-4 text-gray-700">用户名</label>
                                        <input class="form-control form-control-lg" type="text" name="username" id="username" autocomplete="off" placeholder="用户名" />
                                    </div>
                                    <div class="fv-row mb-10">
                                        <div class="d-flex flex-stack mb-2">
                                            <label class="form-label fs-4 text-gray-700 mb-0">密码</label>
                                            @*<a href="#Pane_Forgot" class="link-primary fs-4">忘记密码</a>*@
                                        </div>
                                        <input class="form-control form-control-lg" type="password" name="password" id="password" autocomplete="off" placeholder="密码" />
                                    </div>

                                    <!--begin::Actions-->
                                    <div class="text-center">
                                        <button type="submit" class="btn btn-lg btn-bg-info w-100 mb-5">
                                            <span class="indicator-label text-white">登录</span>
                                            <span class="indicator-progress">
                                                Please wait...
                                                <span class="spinner-border spinner-border-sm align-middle ms-2"></span>
                                            </span>
                                        </button>
                                        
                                        @if (set.AllowRegister)
                                        {
                                            <a id="btnRegister" href="#Pane_Register" class="btn btn-lg btn-bg-light btn-active-info w-100 mb-5 nav-link" onclick="register()">注册</a>    
                                        }
                                    </div>
                                </form>
                                <!--end::Form-->
                            </div>
                            <!-- 找回密码 -->
                            <div id="Pane_Forgot" class="tab-pane fade">

                            </div>
                            <!-- 注册用户 -->
                            <div id="Pane_Register" class="tab-pane fade">
                                <form action="@Url.Action("Register", "User", new {r = set.ReturnUrl })" method="post">
                                    <div class="fv-row mb-5">
                                        <input class="form-control form-control-lg" type="email" name="email" id="reg_email" placeholder="输入您的邮箱地址" autocomplete="off" />
                                    </div>
                                    <div class="fv-row mb-5">
                                        <input class="form-control form-control-lg" type="text" name="username" id="reg_username" placeholder="用户名" autocomplete="off" />
                                    </div>
                                    <div class="fv-row mb-5">
                                        <input class="form-control form-control-lg" type="password" name="password" id="reg_password" placeholder="密码" autocomplete="off" />
                                    </div>
                                    <div class="fv-row mb-5">
                                        <input class="form-control form-control-lg" type="password" name="password2" id="reg_password2" placeholder="确认密码" autocomplete="off" />
                                    </div>

                                    <!--begin::Actions-->
                                    <div class="text-center">
                                        <button type="submit" class="btn btn-lg btn-bg-info w-100 mb-5">
                                            <span class="indicator-label text-white">注册</span>
                                            <span class="indicator-progress">
                                                Please wait...
                                                <span class="spinner-border spinner-border-sm align-middle ms-2"></span>
                                            </span>
                                        </button>

                                        <a href="#Pane_Login" class="btn btn-lg btn-bg-light btn-active-info w-100 mb-5 nav-link" onclick="returnLogin()">返回登录</a>
                                    </div>
                                </form>
                            </div>
                        </div>

                        @await Html.PartialAsync("Login_OAuth")
                    </div>
                    
                </div>
                <!--end::Wrapper-->
                <!--end::Content-->

                <div class="d-flex flex-center flex-column flex-wrap p-5 pb-3">
                    <div class="d-flex flex-center fs-10 text-muted">
                        <a>@NewLife.Cube.Setting.Current.Copyright</a>
                        <a>&nbsp;&nbsp;VER: @SysConfig.Current.Version</a>
                    </div>
                    <div class="d-flex flex-center fw-bold fs-10">
                        <a href="https://www.beianx.cn/" class="text-muted text-hover-primary">
                           @NewLife.Cube.Setting.Current.Registration
                        <a/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="~/assets/plugins/global/plugins.bundle.js"></script>
    <script src="~/assets/js/scripts.bundle.js"></script>

    <script>
        function returnLogin(){
            var paneLogin = document.querySelector('#Pane_Login');
            paneLogin.setAttribute("class", "tab-pane fade show active");

            var paneRegister = document.querySelector("#Pane_Register");
            paneRegister.setAttribute("class", "tab-pane fade");
        }

        function register() {
            var paneRegister = document.querySelector("#Pane_Register");
            paneRegister.setAttribute("class", "tab-pane fade show active");

            var paneLogin = document.querySelector("#Pane_Login");
            paneLogin.setAttribute("class", "tab-pane fade");
        }
    </script>
</body>
</html>
